package com.gofun.report.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gofun.common.wzc.car.APIClient;
import com.gofun.common.wzc.vo.RealtimePositionDetail;
import com.gofun.common.wzc.vo.StatusDetail;
import com.gofun.common.wzc.vo.mq.WzcVo;

public class WZCUtil {
	
	private static Logger logger = LoggerFactory.getLogger(WZCUtil.class);
	
	
	public static RealtimePositionDetail realtimePositionDetail(WzcVo vo) {
		RealtimePositionDetail positionDetail = null;
		try {
			// 发送
			 positionDetail = APIClient.realtimePositionDetail(vo.getLpNum(), vo.getDeviceNum());
			// 数据库操作
			if (positionDetail == null || positionDetail.getLongitude() == 0 || positionDetail.getLatitude() == 0)  {
//				logger.info("carId="+vo.getCarId()+",deviceNum="+vo.getDeviceNum()+" ,没有数据,丢弃报文 positionDetail="+positionDetail);
				return null;
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
		return positionDetail;
	}
	
	public static StatusDetail statusDetail(WzcVo vo) {
		StatusDetail statusDetail = null;
		try {
			statusDetail = APIClient.statusDetail(vo.getLpNum(),vo.getDeviceNum());
			
			if(statusDetail==null){
//				logger.info("carId="+vo.getCarId()+",deviceNum="+vo.getDeviceNum()+" ,没有数据,丢弃报文 statusDetail="+statusDetail); 
				return null;
			}
		} catch (Exception e) {
//			logger.error(e.getMessage(), e);
		}
		return statusDetail;
	}
	
	public static void main(String[] args) {

	}
	
}
